(in-package :TRAPS)
; Generated from #P"macintosh-hd:hd3:CInterface Translator:Source Interfaces:ATASMARTLib.h"
; at Sunday July 2,2006 7:26:50 pm.
; 
;  * Copyright (c) 1998-2003 Apple Computer, Inc. All rights reserved.
;  *
;  * @APPLE_LICENSE_HEADER_START@
;  * 
;  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
;  * 
;  * This file contains Original Code and/or Modifications of Original Code
;  * as defined in and that are subject to the Apple Public Source License
;  * Version 2.0 (the 'License'). You may not use this file except in
;  * compliance with the License. Please obtain a copy of the License at
;  * http://www.opensource.apple.com/apsl/ and read it before using this
;  * file.
;  * 
;  * The Original Code and all software distributed under the License are
;  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
;  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
;  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
;  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
;  * Please see the License for the specific language governing rights and
;  * limitations under the License.
;  * 
;  * @APPLE_LICENSE_HEADER_END@
;  
; #ifndef __ATA_SMART_LIB_H__
; #define __ATA_SMART_LIB_H__

; #if !KERNEL

(require-interface "CoreFoundation/CFPlugIn")

; #if COREFOUNDATION_CFPLUGINCOM_SEPARATE

(require-interface "CoreFoundation/CFPlugInCOM")

; #endif


(require-interface "IOKit/IOReturn")

(require-interface "IOKit/IOTypes")

(require-interface "IOKit/IOCFPlugIn")

(require-interface "IOKit/storage/ata/IOATAStorageDefines")
; #ifdef __cplusplus
#| #|
extern "C" {
#endif
|#
 |#
;  5E659F92-20D3-11D6-BDB5-0003935A76B2 
; ! @defined kIOATASMARTLibFactoryID
;     @discussion UUID for the IOATASMARTInterface Factory. 
; #define kIOATASMARTLibFactoryID			CFUUIDGetConstantUUIDWithBytes(NULL,														0x5E, 0x65, 0x9F, 0x92, 0x20, 0xD3, 0x11, 0xD6,												0xBD, 0xB5, 0x00, 0x03, 0x93, 0x5A, 0x76, 0xB2)
;  24514B7A-2804-11D6-8A02-003065704866 
; ! @defined kIOATASMARTUserClientTypeID
;     @discussion Factory ID for creating an ATA SMART user client. 
; #define kIOATASMARTUserClientTypeID		CFUUIDGetConstantUUIDWithBytes(NULL,														0x24, 0x51, 0x4B, 0x7A, 0x28, 0x04, 0x11, 0xD6,												0x8A, 0x02, 0x00, 0x30, 0x65, 0x70, 0x48, 0x66)
;  08ABE21C-20D4-11D6-8DF6-0003935A76B2 
; ! @defined kIOATASMARTInterfaceID
;     @discussion InterfaceID for IOATASMARTInterface. 
; #define kIOATASMARTInterfaceID			CFUUIDGetConstantUUIDWithBytes(NULL,														0x08, 0xAB, 0xE2, 0x1C, 0x20, 0xD4, 0x11, 0xD6,												0x8D, 0xF6, 0x00, 0x03, 0x93, 0x5A, 0x76, 0xB2)

; #endif	/* !KERNEL */

;  Off-line data collection status byte values ( offset 362 into 
;  device SMART data structure ) See section 8.54.5.8.1 of ATA/ATAPI-6.

(defconstant $kATASMARTOffLineCollectionNeverStarted 0)
(defconstant $kATASMARTOffLineCollectionNoError 2)
(defconstant $kATASMARTOffLineCollectionSuspendedByHost 4)
(defconstant $kATASMARTOffLineCollectionAbortedByHost 5)
(defconstant $kATASMARTOffLineCollectionFatalError 6)
(defconstant $kATASMARTOffLineCollectionMask 127)
;  Self-test execution status values ( offset 363 into 
;  Device SMART data structure ) See section 8.54.5.8.2 of ATA/ATAPI-6.

(defconstant $kATASMARTSelfTestStatusNoError 0)
(defconstant $kATASMARTSelfTestStatusAbortedByHost 1)
(defconstant $kATASMARTSelfTestStatusInterruptedByReset 2)
(defconstant $kATASMARTSelfTestStatusFatalError 3)
(defconstant $kATASMARTSelfTestStatusPreviousTestUnknownFailure 4)
(defconstant $kATASMARTSelfTestStatusPreviousTestElectricalFailure 5)
(defconstant $kATASMARTSelfTestStatusPreviousTestServoFailure 6)
(defconstant $kATASMARTSelfTestStatusPreviousTestReadFailure 7)
(defconstant $kATASMARTSelfTestStatusInProgress 15)
; 
;  *	512 byte Device SMART data structure - 
;  *	See section 8.54.5.8 of T13:1410D (ATA/ATAPI-6).
;  
(defrecord ATASMARTData
   (vendorSpecific1 (:array :UInt8 362))
   (offLineDataCollectionStatus :UInt8)
   (selfTestExecutionStatus :UInt8)
   (secondsToCompleteOffLineActivity (:array :UInt8 2))
   (vendorSpecific2 :UInt8)
   (offLineDataCollectionCapability :UInt8)
   (SMARTCapability (:array :UInt8 2))
   (errorLoggingCapability :UInt8)
   (vendorSpecific3 :UInt8)
   (shortTestPollingInterval :UInt8)
                                                ;  expressed in minutes 
   (extendedTestPollingInterval :UInt8)
                                                ;  expressed in minutes 
   (reserved (:array :UInt8 12))
   (vendorSpecific4 (:array :UInt8 125))
   (checksum :UInt8)
)
; 
;  *	512 byte Device SMART data thresholds structure. Not
;  *	strictly part of ATA/ATAPI-6.
;  
(defrecord ATASMARTDataThresholds
   (vendorSpecific1 (:array :UInt8 362))
   (vendorSpecific2 (:array :UInt8 149))
   (checksum :UInt8)
)
(defrecord ATASMARTLogEntry
   (numberOfSectors :UInt8)
   (reserved :UInt8)
)
(defrecord ATASMARTLogDirectory
   (SMARTLoggingVersion (:array :UInt8 2))
   (entries (:array :ATASMARTLOGENTRY 255))
)

; #if !KERNEL
; ! 
;  *	@struct IOATASMARTInterface
;  *	@abstract Self-Monitoring, Analysis, and Reporting
;  *	Technology Interface.  
;  *	@discussion See section 6.14 and section 8.54 of T13:1410D ATA/ATAPI-6
;  *	for details on Self-Monitoring, Analysis, and Reporting Technology
;  *	feature set.
;  
(defrecord IOATASMARTInterface
#|
   (NIL :iunknown_c_guts)|#
   (version :UInt16)
   (revision :UInt16)
                                                ;  
; 	 * MANDATORY API support. If the device claims SMART feature set compliance, it
; 	 * must implement the following functions.
; 	 
                                                ; !
; 		@function SMARTEnableDisableOperations
; 		@abstract toggle SMART Operations.
; 		@discussion See section 8.54.1 and 8.54.3 of ATA/ATAPI-6.
; 		@param enable Passing true will ENABLE SMART operations,
; 		false will DISABLE SMART operations.
; 		@result Returns kIOReturnSuccess if successful, kIOReturnNoDevice
; 		if there is no connection to an IOService, kIOReturnExclusiveAccess
; 		if it is already opened by another client.
; 	
   (SMARTEnableDisableOperations (:pointer :callback));(IOReturn (void * interface , Boolean enable))
                                                ; !
; 		@function SMARTEnableDisableAutosave
; 		@abstract toggle SMART Autosave.
; 		@discussion	See section 8.54.2 of ATA/ATAPI-6.
; 		@param enable Passing true will ENABLE SMART Autosave, false will
; 		DISABLE SMART Autosave.
; 		@result Returns kIOReturnSuccess if successful, kIOReturnNoDevice
; 		if there is no connection to an IOService, kIOReturnExclusiveAccess
; 		if it is already opened by another client.
; 	
   (SMARTEnableDisableAutosave (:pointer :callback));(IOReturn (void * interface , Boolean enable))
                                                ; !
; 		@function SMARTReturnStatus
; 		@abstract see if device has detected a threshold exceeded condition.
; 		@discussion	The caller will poll this function and if
; 		exceededCondition is non-zero and we returned kIOReturnSuccess the
; 		device threshold exceeded condition. This would prompt the caller
; 		to call ATASMARTReadData to get more information. See section
; 		8.54.7 of ATA/ATAPI-6.
; 		@param if exceededCondition is non-zero the device threshold
; 		exceeded condition.
; 		@result Returns kIOReturnSuccess if successful, kIOReturnNoDevice
; 		if there is no connection to an IOService, kIOReturnExclusiveAccess
; 		if it is already opened by another client.	
; 	
   (SMARTReturnStatus (:pointer :callback))     ;(IOReturn (void * interface , Boolean * exceededCondition))
                                                ;  
; 	 * OPTIONAL API support. If the device claims SMART feature set compliance, it
; 	 * may implement one or more of the following functions. Please consult the
; 	 * technical manual for the device to see what functions are supported.
; 	 
                                                ; !
; 		@function SMARTExecuteOffLineImmediate
; 		@abstract immediately initiate collection of SMART data.
; 		@discussion	See section 8.54.4 of ATA/ATAPI-6.
; 		@param passing true will collect "off-line" extended test,
; 		false short test.
; 		@result Returns kIOReturnSuccess if successful,
; 		kIOReturnNoDevice if there is no connection to an IOService,
; 		kIOReturnExclusiveAccess if it is already opened by another client.	
; 	
   (SMARTExecuteOffLineImmediate (:pointer :callback));(IOReturn (void * interface , Boolean extendedTest))
                                                ; !
; 		@function SMARTReadData
; 		@abstract Retrieves 512 byte device SMART data structure.
; 		@discussion	See section 8.54.5 of ATA/ATAPI-6.
; 		Will return an appropiate error if command can not be completed.
; 	
   (SMARTReadData (:pointer :callback))         ;(IOReturn (void * interface , ATASMARTData * data))
                                                ; !
; 		@function SMARTValidateReadData
; 		@abstract Test the integrity of the device SMART data structure.
; 		@discussion	The data structure checksum is the two's complement
; 		of the sum of the first 511 bytes in the data structure. The sum
; 		of all 512 bytes will be zero when the checksum is correct. See
; 		section 8.54.5.8.7 of ATA/ATAPI-6. Will return an error if
; 		checksum fails.
; 	
   (SMARTValidateReadData (:pointer :callback)) ;(IOReturn (void * interface , const ATASMARTData * data))
                                                ; !
; 		@function SMARTReadDataThresholds
; 		@abstract Retrieves 512 byte device SMART data thresholds structure.
; 		@discussion	Retrieves 512 byte device SMART data thresholds structure.
; 		This command is not defined as part of ATA/ATAPI-6, but is implemented
; 		by a large variety of manufacturers. Will return an appropiate error if
; 		command can not be completed.
; 	
   (SMARTReadDataThresholds (:pointer :callback));(IOReturn (void * interface , ATASMARTDataThresholds * dataThresholds))
                                                ; !
; 		@function SMARTReadLogDirectory
; 		@abstract Reads the 512-byte log directory.
; 		@discussion	The log directory is a directory of all possible
; 		SMART logs available from the drive.
; 	
   (SMARTReadLogDirectory (:pointer :callback)) ;(IOReturn (void * interface , ATASMARTLogDirectory * logData))
                                                ; !
; 		@function SMARTReadLogAtAddress
; 		@abstract Reads the 512-byte log at the specified logOffset in the log.
; 		@discussion	Reads the 512-byte log at the specified logOffset in the log.
; 		See section 8.54.6.4 of ATA/ATAPI-6.
; 	
   (SMARTReadLogAtAddress (:pointer :callback)) ;(IOReturn (void * interface , UInt32 logOffset , void * buffer , UInt32 size))
                                                ; !
; 		@function SMARTWriteLogAtAddress
; 		@abstract Writes to the 512-byte log at the specified logOffset in the log.
; 		@discussion	Writes to the 512-byte log at the specified logOffset in the log.
; 		See section 8.54.8.4 of ATA/ATAPI-6.
; 	
   (SMARTWriteLogAtAddress (:pointer :callback));(IOReturn (void * interface , UInt32 logOffset , const void * buffer , UInt32 size))
                                                ; !
; 		@function GetATAIdentifyData
; 		@abstract Reads the 512-byte data provided by the drive in response
; 		to the ATA IDENTIFY DEVICE command.
; 		@discussion Reads the 512-byte data provided by the drive in response
; 		to the ATA IDENTIFY DEVICE command.
; 		See section 8.15 of ATA/ATAPI-6.
; 		The data placed in buffer is guaranteed to be in native endian form on return.
; 		(i.e. it will be byte swapped on big endian platforms, so the caller need not
; 		do anything)
; 		@param interface A valid IOATASMARTInterface**.
; 		@param buffer A valid buffer.
; 		@param inSize The number of bytes to place in the buffer.
; 		@param outSize The number of bytes placed in the buffer. Can be NULL if the information
; 		is not required by the caller.
; 		@return An IOReturn result code. If inSize is greater than 512 or less than 1,
; 				kIOReturnBadArgument is returned.
; 	
   (GetATAIdentifyData (:pointer :callback))    ;(IOReturn (void * interface , void * buffer , UInt32 inSize , UInt32 * outSize))
)
; #ifdef __cplusplus
#| #|
}
#endif
|#
 |#

; #endif	/* !KERNEL */


; #endif	/* __ATA_SMART_LIB_H__ */


(provide-interface "ATASMARTLib")